<?php

/**
 * Description of Util_UiContentProvider
 *
 * @author Young Suk Ahn
 */
class Util_Session {
	
	public static function getUserInfo() 
	{
		$userInfo = Util_Session::get(SNAME_USER, 
			new ArrayObject(
				array('userSid'=> SID_NIL
					, 'userId' => '_anonymous_'
					, 'dateFormat' => 'm/d/Y'
					, 'dateFormatJs' => 'mm/dd/yyyy'))
			);
		
		return $userInfo;
	}
	
	public static function setUserInfo($userDto)
	{
		$retval = Util_Session::set(SNAME_USER, 
			array('userSid' => $userDto->sid
				, 'userId' => $userDto->id
				, 'userProfileImageSid' => $userDto->profileImageSid
				, 'userName' => $userDto->displayName
				, 'userStatus' => $userDto->status
				, 'userLangCd' => $userDto->defaultLangCd
				, 'dateFormat'=>'m/d/Y'
				, 'dateFormatJs'=>'mm/dd/yyyy'
			));
		
		return $retval;
	}
	
	////////// Using PHP Native //////////
	
	public static function get($key, $defaultVal = null) 
	{
		// Using PHP native session
		if (session_id() == "")
			 session_start();
		$retval = isset($_SESSION[$key]) ? $_SESSION[$key] : $defaultVal;
		
		return $retval;
	}

	public static function set($key, $value) 
	{
		// Using PHP native session
		if (session_id() == "")
			 session_start();
		$_SESSION[$key] = $value;
		
		return $value;
	}
	
	public static function delete($key)
	{
		// Using PHP native session
		if (session_id() == "")
			 session_start();
		 unset($_SESSION[$key]);

	}
	
	public static function destroy()
	{
		// Using PHP native session
		if (session_id() == "")
			 session_start();
		session_destroy();
	}
	
	////////// Using Kohana //////////
	/*
	public static function get($key, $defaultVal = NULL) 
	{
		// Using Kohana's session
		$retval = Session::instance()->get($key, $defaultVal);
		return $retval;
	}

	public static function set($key, $value) 
	{
		// Using Kohana's session
		return Session::instance()->set($key, $value);
	}
	
	public static function delete($key)
	{
		// Using Kohana's session
		Session::instance()->delete($key);
	}
	
	public static function destroy()
	{
		// Using Kohana's session
		Session::instance()->destroy();
	}*/
}